<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Execute the query</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongocursor.dead.html">« MongoCursor::dead</a></li>
      <li style="float: right;"><a href="mongocursor.explain.html">MongoCursor::explain »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mongocursor.html">MongoCursor</a></li>
    <li>Execute the query</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongocursor.doquery" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCursor::doQuery</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.0 &lt;1.6.0)</p><p class="refpurpose"><span class="refname">MongoCursor::doQuery</span> &mdash; <span class="dc-title">Execute the query</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-mongocursor.doquery-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">protected</span> <span class="methodname"><strong>MongoCursor::doQuery</strong></span>(): <span class="type"><span class="type void">void</span></span></div>

  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    Please do not use me.
   </p>
  </div>
  <p class="para">
   This function actually queries the database.  All queries and commands go 
   through this function.  Thus, this function can be overridden to provide 
   custom query handling.  
  </p>
  <p class="para">
   This handles serializing your query, sending it to the database, receiving a 
   response, and deserializing it.  Thus, if you are planning to override this,
   your code should probably call out to the original to use the existing
   functionality (see the example below).
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-mongocursor.doquery-parameters">
  <h3 class="title">Parameters</h3>    
  <p class="para">This function has no parameters.</p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-mongocursor.doquery-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   <strong><code>null</code></strong>.
  </p>
 </div>

 
 <div class="refsect1 errors" id="refsect1-mongocursor.doquery-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws <a href="class.mongoconnectionexception.html" class="classname">MongoConnectionException</a> if it cannot reach the 
   database.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-mongocursor.doquery-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongo 1.2.11</td>
       <td>Emits <strong><code>E_DEPRECATED</code></strong> when used.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongocursor.doquery-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="mongocursor.doquery.example.basic">
    <p><strong>Example #1 <span class="function"><strong>MongoCursor::doQuery()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     You could override this function to attempt a query on a secondary and, if
     that fails, try it again on the primary.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">MyCursor&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">MongoCursor&nbsp;</span><span style="color: #007700">{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;protected&nbsp;function&nbsp;</span><span style="color: #0000BB">doQuery</span><span style="color: #007700">()&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slaveOkay</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">MongoCursor</span><span style="color: #007700">::</span><span style="color: #0000BB">doQuery</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;catch(</span><span style="color: #0000BB">MongoCursorException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">slaveOkay</span><span style="color: #007700">(</span><span style="color: #0000BB">false</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">MongoCursor</span><span style="color: #007700">::</span><span style="color: #0000BB">doQuery</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>
 
</div></div></div></body></html>